﻿<script language="javascript" type="text/javascript" src="<?php echo base_url().'assets/tiny_mce/tiny_mce.js'; ?>"></script>
<script language="javascript" type="text/javascript">
  tinyMCE.init({
	mode : "exact",
    theme : "advanced",
	plugins : "advimage,advlink,media,contextmenu,paste,insertdatetime,table,emotions,pagebreak",
    editor_deselector : "NoEditor",
    entity_encoding : "raw",
    elements : "ccontent",
	width : 700,
	height : 400,
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,fontsizeselect,forecolor,backcolor,link,unlink,anchor,image,separator,code",
    theme_advanced_buttons2 : "pastetext,pasteword,|,hr,separator,sub,sup,separator,outdent,indent,undo,redo,tablecontrols",


    theme_advanced_buttons3 : "",
    theme_advanced_buttons4 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    convert_urls : false,
    file_browser_callback : 'ajaxfilemanager',
    accessibility_warnings : false
  });
   /*function ajaxfilemanager (field_name, url, type, win) 
   {
	   var fileBrowserWindow = new Array();
	   fileBrowserWindow['title'] = 'File Browser';
	   //fileBrowserWindow['file'] = "my_cms_script.php" + "?type=" + type;
	   fileBrowserWindow['file'] = "plugins/ajaxfilemanager/ajaxfilemanager.php" + "?type=" + type;
	   fileBrowserWindow['width'] = '420';
	   fileBrowserWindow['height'] = '400';
	   tinyMCE.activeEditor.windowManager.open(fileBrowserWindow, { window : win, resizable : 'yes', inline : 'yes' });
	   return false;
   }*/

	function ajaxfilemanager(field_name, url, type, win) {
		/*var ajaxfilemanagerurl = "../../../../assets/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";
		switch (type) {
			case "image":
				break;
			case "media":
				break;
			case "flash": 
				break;
			case "file":
				break;
			default:
				return false;
		}*/
		tinyMCE.activeEditor.windowManager.open({
			url: "../../../../assets/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php",
			width: 750,
			height: 400,
			inline : "yes",
			close_previous : "no"
		},{
			window : win,
			input : field_name
		});
	}
</script>
<div id="pagecontent">
<?php 
	if($this->session->flashdata('message')!='')
	{ 
		
?>
<div id="sponsorAdDiv" style="visibility:hidden">
<table width="305px" height="50px" bgcolor="#FF0000"><tr><td>
<table width="300px" height="45px" bgcolor="#FFFFCC"><tr><td align="center" valign="middle">
<?php echo $this->session->flashdata('message'); ?>
</p>
</td></tr></table></td></tr></table>
</div>
<?php
	}
?>
<?php
if ($this->uri->segment(4))
{
?>
<div id="add" style="cursor:pointer; float:right; font-weight:bold; color:#FF0066;"><span id="actionname" style="text-decoration:overline">UPDATE</span> <img  src="<?php echo base_url(); ?>assets/img/icon-32-new.png" title="<?php echo $this->lang->line('m_addmenu'); ?>" align="absmiddle"/> </div>

<div id="addbigcontent">
  <div id='addmenu'> 
  <?php
  	foreach($current_information as $current)
	{
		$title=$current['title'];
		$content=$current['content'];
		$image=$current['thumb_img'];
		$current_id=$current['id'];
	}
  ?>
<form action="<?php echo base_url().index_page(); ?>/adminpage/cpanel/update_information_frontpage/" method="post" name="adminForm" id="adminForm" autocomplete="off" enctype="multipart/form-data">
    <fieldset style="border:none">
    <div id="addnew"><div align="center" class="error_validate" id="error_message"></div>
      <div>
        <label for="csection">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Section name</label>
         <span id="csection" style="font-weight:bold"><?php echo $title; ?></span>
      </div>
	  <div>
			<label for="clabel_thumnail">Thumbnail image</label>
			<input id="clabel_thumnail" name="userfile" type="file" size="38" maxlength="50" value="" onblur="checkExt()"/> 
		<div align="center" style="background-color:#FFFFCC;color:#BBB; width:90px; height:70px; z-index:1;position: absolute; top:270px; left:550px;" >
		<?php
		if ($image=='')
		{
			echo '<span style="width:110px; height:90px;"><br /><br /><strong>No Image</strong></span>';
		}
		else
		{
		?>
		<img src="<?php echo base_url().'assets/images/'.$image; ?>" width="90" height="70" />
		<?php
		}
		?>
		</div>
		</div>
	  
      <div>
        <label for="ccontent">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Content</label>
        <textarea id="ccontent"  name="content" cols="80" rows="8"><?php echo $content; ?></textarea>
      </div>
    </div>
    <input type="hidden" name="myurl" value="<?php echo base_url().index_page().$this->uri->uri_string(); ?>" />
    <input type="hidden" id="id" name="id" value="<?php echo $current_id; ?>" />
    <input type="hidden" name="task" value="" />
    <div class="toolbar"  align="center">
      <table width="160px" border="0" align="center" cellpadding="5">
        <tr>
          <td align="center"><div id="mybutton" onclick="javascript: submitbutton('save')"><a href="#"><span class="icon-32-save" title="Update"></span>Update</a></div></td>
          <td align="center"><div id="mybutton2"><a href="<?php echo base_url().index_page()."/adminpage/cpanel/information_manager/"; ?>"><span class="icon-32-cancel" title="Cancel"> </span>Cancel</div></a></td>
        </tr>
      </table>
    </div>
  </fieldset>
</form><div align="center"><br /><hr width="400px" /><br /></div>

  </div> 
  <br />
</div>

<?php
}
?>
<div id="listmenu" align="center" style="width:100%; padding-left:0px;"> 
<table width="80%" id="tablesorter-demo" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
  <thead>
  <tr>
    <th align="center" width="25%">Section name</th>
    <th align="center" width="50%">Description</th>
    <th align="center" width="10%" class="{sorter: false}"><?php echo $this->lang->line('table_header_action'); ?></th>
  </tr>
  </thead>
  <tbody>
   <?php 
				//var_dump($information_manager);
				$i=0;
				foreach($information_manager as $row)
				{
					$td_bg=($i%2==0)?"":" background-color:#f0f0f6";
					echo "<tr><td align='center' style='padding-left:10px;".$td_bg.";'><div id='mysection".$row['id']."'>".$row['title']."</div></td><td style='padding-left:10px;".$td_bg.";'><div id='myanswer".$row['id']."'>".substr($row['content'],0,100)." ...</div></td><td align='center' width='30%' style='padding-left:10px;".$td_bg.";'><a  style='color:#FF6600;cursor:pointer' href='".base_url().index_page()."/adminpage/cpanel/information_manager/".$row['id']."/'>Edit</a></td></tr>";
					$i++;
				}
	?> 
  </tbody>
</table>
  </div> 
<p>&nbsp;</p>
</div>
<script>
function show_edit_faq(id)
{
	document.getElementById("id").value=id;
	document.getElementById("error_message").innerHTML="";
	document.getElementById("csection").innerHTML=$('#mysection'+id).html();
	document.getElementById("csorting").value=$('#mysorting'+id).html();
	$('#add').show();
	$.ajax(
	{	
		type: "POST",
		url: "<?php echo base_url().index_page(); ?>/adminpage/cpanel/get_news_item/",
		success: function(result)
		{
			//alert($('#ccontent').html(result));
			tinyMCE.activeEditor.setContent(result);
			
			$('#addbigcontent').show(400);
			document.getElementById("id").value=id;
			
		}
	});
	$.ajax(
	{   
		type: "POST",
		data: {
			'id': id
			},
		dataType: 'json',
		url: "<?php echo base_url().index_page(); ?>/adminpage/cpanel/get_news_item/",
		success: function(result)
		{
			$("#cname").val(result[0].name);
			$("#description").val(result[0].info);
			$("#sorting").val(result[0].sort_order);
		 	$("#publish input[value='"+result[0].active+"']").attr("checked", 'checked');
			var op=result[0].active==1?0:1;
			$("#publish input[value='"+ op +"']").removeAttr("checked");
			$("#special input[value='"+result[0].special+"']").attr("checked", 'checked');
			var ops=result[0].special==1?0:1;
			$("#special input[value='"+ ops +"']").removeAttr("checked");
		}
	});
	$('#imageblock').html('<img src="http://localhost/MyBackend/upload/news/company/cover_back.jpg"'+' width="100" height="80" style="margin-top:5px"/>');
}

	$(document).ready(function() { 
    $("#tablesorter-demo").tablesorter({ 
        // pass the headers argument and assing a object 
        headers: { 
            // assign the third column (we start counting zero) 
            2: { 
                // disable it by setting the property sorter to false 
                sorter: false 
            } 
        } 
    }); 
});
function checkvalidate() 
{
	canswer=tinyMCE.activeEditor.getContent();   // get the content of Textarea
	
	if (canswer=="")
	{
		document.getElementById("error_message").innerHTML="Content is required.";
		return 0;
	}
	else
	{
		return 1;
	}
}
</script>